import React, { Component } from 'react';
import Home from './pages/home';
import Layout from './component/layout';
import Login from './pages/login';
import UserList from './pages/user';
import ProductRouter from './pages/product/router';
import OrderList from './pages/order';
import OrderDetail from './pages/order/detail';
import Error from './pages/error';
import { HashRouter as Router, Switch, Route, Redirect} from 'react-router-dom';
class App extends Component {
  render() {
    return (
      <div>
        <Router>
          <Switch>
            <Route path="/login" component={Login} />
            <Route path="/" render={() => 
              <Layout>
                <Switch>
                  <Route path="/home" component={Home} />
                  <Redirect exact from="/user" to="/user/index" />
                   <Route path="/order/index" component={OrderList} />
                   <Redirect exact from="/order" to="/order/index" />
                   <Route path="/order/detail/:orderNumber" component={OrderDetail} />
                  <Route path="/user/index" component={UserList} />
                  <Route path="/product" component={ProductRouter} />
                  <Route path="/order" component={Home} />
                  <Route component={Error} />
                </Switch>
              </Layout>
            }/>
            </Switch>
        </Router>
      </div>
    );
  }
}

export default App;
